<script setup >
import { onMounted, ref } from "vue";
import { getDetail } from "@/apis/detail";
import powerSet from "./power-set";

// 商品数据
const goods = ref({
  id: "4026450",
  name: "趣味小恐龙绣花，男童灯芯绒衬衫",
  spuCode: "4026450",
  desc: "趣味小恐龙绣花，满版老虎印花，5色可选",
  price: "89.00",
  oldPrice: "89.00",
  discount: 1.0,
  inventory: 219733630,
  brand: {
    id: "spider99999999999",
    name: "传智自有品牌",
    nameEn: "chuanzhi",
    logo: "https://yanxuan-item.nosdn.127.net/f6ddd429632de6170900dc2fbc541fd8.png?type=webp&imageView&thumbnail=78x78&quality=95",
    picture:
      "https://yanxuan-item.nosdn.127.net/f6ddd429632de6170900dc2fbc541fd8.png?type=webp&imageView&thumbnail=78x78&quality=95",
    type: null,
    desc: null,
    place: null,
  },
  salesCount: 172,
  commentCount: 1,
  collectCount: 0,
  mainVideos: [],
  videoScale: 1,
  mainPictures: [
    "https://yanxuan-item.nosdn.127.net/e68d406a58622a8d850de442aacfcf2e.jpg",
    "https://yanxuan-item.nosdn.127.net/5cc2007211c561d9bfe5426fe9d943de.jpg",
    "https://yanxuan-item.nosdn.127.net/34408ad262b83e68c98cd7b6855bb1e4.jpg",
    "https://yanxuan-item.nosdn.127.net/f15f22c3698d1731ec4753fbc1d82488.jpg",
    "https://yanxuan-item.nosdn.127.net/619319e12a8a04f642a7843f85531ab4.jpg",
  ],
  specs: [
    {
      name: "颜色",
      id: "1482372728260526083",
      values: [
        {
          name: "灰半蓝",
          picture:
            "https://yanxuan-item.nosdn.127.net/2df51fa62b5719c2553249055eaaa02a.png",
          desc: "T恤/polo/衬衫-销售属性颜色-灰半蓝-规格属性图片",
        },
        {
          name: "虎虎生威",
          picture:
            "https://yanxuan-item.nosdn.127.net/c4295d879800d3280c483faa043ad6f2.png",
          desc: "T恤/polo/衬衫-销售属性颜色-虎虎生威-规格属性图片",
        },
        {
          name: "暗绿色",
          picture:
            "https://yanxuan-item.nosdn.127.net/df5c51c0772ef8948449dd8cb5d9b493.png",
          desc: "T恤/polo/衬衫-销售属性颜色-暗绿色-规格属性图片",
        },
        {
          name: "米白",
          picture:
            "https://yanxuan-item.nosdn.127.net/25320ac8a79b26b5baff8337010e9670.png",
          desc: "T恤/polo/衬衫-销售属性颜色-米白-规格属性图片",
        },
        {
          name: "极地黄",
          picture:
            "https://yanxuan-item.nosdn.127.net/959423192703db495c39ee7ab7046f38.png",
          desc: "T恤/polo/衬衫-销售属性颜色-极地黄-规格属性图片",
        },
      ],
    },
    {
      name: "尺码",
      id: "1482372729053249538",
      values: [
        {
          name: "110/5T",
          picture: null,
          desc: "T恤/polo/衬衫-销售属性尺码-110/5T-规格属性图片",
        },
        {
          name: "120/6T",
          picture: null,
          desc: "T恤/polo/衬衫-销售属性尺码-120/6T-规格属性图片",
        },
        {
          name: "130/8T",
          picture: null,
          desc: "T恤/polo/衬衫-销售属性尺码-130/8T-规格属性图片",
        },
        {
          name: "73/18M",
          picture: null,
          desc: "T恤/polo/衬衫-销售属性尺码-73/18M-规格属性图片",
        },
        {
          name: "80/24M",
          picture: null,
          desc: "T恤/polo/衬衫-销售属性尺码-80/24M-规格属性图片",
        },
        {
          name: "90/3T",
          picture: null,
          desc: "T恤/polo/衬衫-销售属性尺码-90/3T-规格属性图片",
        },
        {
          name: "100/4T",
          picture: null,
          desc: "T恤/polo/衬衫-销售属性尺码-100/4T-规格属性图片",
        },
      ],
    },
  ],
  skus: [
    {
      id: "300476623",
      skuCode: "300476623",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 4935,
      picture:
        "https://yanxuan-item.nosdn.127.net/25320ac8a79b26b5baff8337010e9670.png",
      specs: [
        {
          name: "颜色",
          valueName: "米白",
        },
        {
          name: "尺码",
          valueName: "73/18M",
        },
      ],
    },
    {
      id: "300476624",
      skuCode: "300476624",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 2726,
      picture:
        "https://yanxuan-item.nosdn.127.net/25320ac8a79b26b5baff8337010e9670.png",
      specs: [
        {
          name: "颜色",
          valueName: "米白",
        },
        {
          name: "尺码",
          valueName: "80/24M",
        },
      ],
    },
    {
      id: "300476625",
      skuCode: "300476625",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 1089,
      picture:
        "https://yanxuan-item.nosdn.127.net/25320ac8a79b26b5baff8337010e9670.png",
      specs: [
        {
          name: "颜色",
          valueName: "米白",
        },
        {
          name: "尺码",
          valueName: "90/3T",
        },
      ],
    },
    {
      id: "300476626",
      skuCode: "300476626",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 2044,
      picture:
        "https://yanxuan-item.nosdn.127.net/25320ac8a79b26b5baff8337010e9670.png",
      specs: [
        {
          name: "颜色",
          valueName: "米白",
        },
        {
          name: "尺码",
          valueName: "100/4T",
        },
      ],
    },
    {
      id: "300476627",
      skuCode: "300476627",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 9304,
      picture:
        "https://yanxuan-item.nosdn.127.net/25320ac8a79b26b5baff8337010e9670.png",
      specs: [
        {
          name: "颜色",
          valueName: "米白",
        },
        {
          name: "尺码",
          valueName: "110/5T",
        },
      ],
    },
    {
      id: "300476628",
      skuCode: "300476628",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 4135,
      picture:
        "https://yanxuan-item.nosdn.127.net/25320ac8a79b26b5baff8337010e9670.png",
      specs: [
        {
          name: "颜色",
          valueName: "米白",
        },
        {
          name: "尺码",
          valueName: "120/6T",
        },
      ],
    },
    {
      id: "300476629",
      skuCode: "300476629",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 7536,
      picture:
        "https://yanxuan-item.nosdn.127.net/25320ac8a79b26b5baff8337010e9670.png",
      specs: [
        {
          name: "颜色",
          valueName: "米白",
        },
        {
          name: "尺码",
          valueName: "130/8T",
        },
      ],
    },
    {
      id: "300476630",
      skuCode: "300476630",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 3874,
      picture:
        "https://yanxuan-item.nosdn.127.net/959423192703db495c39ee7ab7046f38.png",
      specs: [
        {
          name: "颜色",
          valueName: "极地黄",
        },
        {
          name: "尺码",
          valueName: "73/18M",
        },
      ],
    },
    {
      id: "300476631",
      skuCode: "300476631",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 5169,
      picture:
        "https://yanxuan-item.nosdn.127.net/959423192703db495c39ee7ab7046f38.png",
      specs: [
        {
          name: "颜色",
          valueName: "极地黄",
        },
        {
          name: "尺码",
          valueName: "80/24M",
        },
      ],
    },
    {
      id: "300476632",
      skuCode: "300476632",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 383,
      picture:
        "https://yanxuan-item.nosdn.127.net/959423192703db495c39ee7ab7046f38.png",
      specs: [
        {
          name: "颜色",
          valueName: "极地黄",
        },
        {
          name: "尺码",
          valueName: "90/3T",
        },
      ],
    },
    {
      id: "300476633",
      skuCode: "300476633",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 5617,
      picture:
        "https://yanxuan-item.nosdn.127.net/959423192703db495c39ee7ab7046f38.png",
      specs: [
        {
          name: "颜色",
          valueName: "极地黄",
        },
        {
          name: "尺码",
          valueName: "100/4T",
        },
      ],
    },
    {
      id: "300476634",
      skuCode: "300476634",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 9405,
      picture:
        "https://yanxuan-item.nosdn.127.net/959423192703db495c39ee7ab7046f38.png",
      specs: [
        {
          name: "颜色",
          valueName: "极地黄",
        },
        {
          name: "尺码",
          valueName: "110/5T",
        },
      ],
    },
    {
      id: "300476635",
      skuCode: "300476635",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 8309,
      picture:
        "https://yanxuan-item.nosdn.127.net/959423192703db495c39ee7ab7046f38.png",
      specs: [
        {
          name: "颜色",
          valueName: "极地黄",
        },
        {
          name: "尺码",
          valueName: "120/6T",
        },
      ],
    },
    {
      id: "300476636",
      skuCode: "300476636",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 3057,
      picture:
        "https://yanxuan-item.nosdn.127.net/959423192703db495c39ee7ab7046f38.png",
      specs: [
        {
          name: "颜色",
          valueName: "极地黄",
        },
        {
          name: "尺码",
          valueName: "130/8T",
        },
      ],
    },
    {
      id: "300476637",
      skuCode: "300476637",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 616,
      picture:
        "https://yanxuan-item.nosdn.127.net/df5c51c0772ef8948449dd8cb5d9b493.png",
      specs: [
        {
          name: "颜色",
          valueName: "暗绿色",
        },
        {
          name: "尺码",
          valueName: "73/18M",
        },
      ],
    },
    {
      id: "300476638",
      skuCode: "300476638",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 2705,
      picture:
        "https://yanxuan-item.nosdn.127.net/df5c51c0772ef8948449dd8cb5d9b493.png",
      specs: [
        {
          name: "颜色",
          valueName: "暗绿色",
        },
        {
          name: "尺码",
          valueName: "80/24M",
        },
      ],
    },
    {
      id: "300476639",
      skuCode: "300476639",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 9161,
      picture:
        "https://yanxuan-item.nosdn.127.net/df5c51c0772ef8948449dd8cb5d9b493.png",
      specs: [
        {
          name: "颜色",
          valueName: "暗绿色",
        },
        {
          name: "尺码",
          valueName: "90/3T",
        },
      ],
    },
    {
      id: "300476640",
      skuCode: "300476640",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 8656,
      picture:
        "https://yanxuan-item.nosdn.127.net/df5c51c0772ef8948449dd8cb5d9b493.png",
      specs: [
        {
          name: "颜色",
          valueName: "暗绿色",
        },
        {
          name: "尺码",
          valueName: "100/4T",
        },
      ],
    },
    {
      id: "300476641",
      skuCode: "300476641",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 7648,
      picture:
        "https://yanxuan-item.nosdn.127.net/df5c51c0772ef8948449dd8cb5d9b493.png",
      specs: [
        {
          name: "颜色",
          valueName: "暗绿色",
        },
        {
          name: "尺码",
          valueName: "110/5T",
        },
      ],
    },
    {
      id: "300476642",
      skuCode: "300476642",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 9650,
      picture:
        "https://yanxuan-item.nosdn.127.net/df5c51c0772ef8948449dd8cb5d9b493.png",
      specs: [
        {
          name: "颜色",
          valueName: "暗绿色",
        },
        {
          name: "尺码",
          valueName: "120/6T",
        },
      ],
    },
    {
      id: "300476643",
      skuCode: "300476643",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 4850,
      picture:
        "https://yanxuan-item.nosdn.127.net/df5c51c0772ef8948449dd8cb5d9b493.png",
      specs: [
        {
          name: "颜色",
          valueName: "暗绿色",
        },
        {
          name: "尺码",
          valueName: "130/8T",
        },
      ],
    },
    {
      id: "300476644",
      skuCode: "300476644",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 7253,
      picture:
        "https://yanxuan-item.nosdn.127.net/2df51fa62b5719c2553249055eaaa02a.png",
      specs: [
        {
          name: "颜色",
          valueName: "灰半蓝",
        },
        {
          name: "尺码",
          valueName: "73/18M",
        },
      ],
    },
    {
      id: "300476645",
      skuCode: "300476645",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 5461,
      picture:
        "https://yanxuan-item.nosdn.127.net/2df51fa62b5719c2553249055eaaa02a.png",
      specs: [
        {
          name: "颜色",
          valueName: "灰半蓝",
        },
        {
          name: "尺码",
          valueName: "80/24M",
        },
      ],
    },
    {
      id: "300476646",
      skuCode: "300476646",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 3980,
      picture:
        "https://yanxuan-item.nosdn.127.net/2df51fa62b5719c2553249055eaaa02a.png",
      specs: [
        {
          name: "颜色",
          valueName: "灰半蓝",
        },
        {
          name: "尺码",
          valueName: "90/3T",
        },
      ],
    },
    {
      id: "300476647",
      skuCode: "300476647",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 9768,
      picture:
        "https://yanxuan-item.nosdn.127.net/2df51fa62b5719c2553249055eaaa02a.png",
      specs: [
        {
          name: "颜色",
          valueName: "灰半蓝",
        },
        {
          name: "尺码",
          valueName: "100/4T",
        },
      ],
    },
    {
      id: "300476648",
      skuCode: "300476648",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 3913,
      picture:
        "https://yanxuan-item.nosdn.127.net/2df51fa62b5719c2553249055eaaa02a.png",
      specs: [
        {
          name: "颜色",
          valueName: "灰半蓝",
        },
        {
          name: "尺码",
          valueName: "110/5T",
        },
      ],
    },
    {
      id: "300476649",
      skuCode: "300476649",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 5625,
      picture:
        "https://yanxuan-item.nosdn.127.net/2df51fa62b5719c2553249055eaaa02a.png",
      specs: [
        {
          name: "颜色",
          valueName: "灰半蓝",
        },
        {
          name: "尺码",
          valueName: "120/6T",
        },
      ],
    },
    {
      id: "300476650",
      skuCode: "300476650",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 7170,
      picture:
        "https://yanxuan-item.nosdn.127.net/2df51fa62b5719c2553249055eaaa02a.png",
      specs: [
        {
          name: "颜色",
          valueName: "灰半蓝",
        },
        {
          name: "尺码",
          valueName: "130/8T",
        },
      ],
    },
    {
      id: "300476651",
      skuCode: "300476651",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 9670,
      picture:
        "https://yanxuan-item.nosdn.127.net/c4295d879800d3280c483faa043ad6f2.png",
      specs: [
        {
          name: "颜色",
          valueName: "虎虎生威",
        },
        {
          name: "尺码",
          valueName: "73/18M",
        },
      ],
    },
    {
      id: "300476652",
      skuCode: "300476652",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 110,
      picture:
        "https://yanxuan-item.nosdn.127.net/c4295d879800d3280c483faa043ad6f2.png",
      specs: [
        {
          name: "颜色",
          valueName: "虎虎生威",
        },
        {
          name: "尺码",
          valueName: "80/24M",
        },
      ],
    },
    {
      id: "300476653",
      skuCode: "300476653",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 4629,
      picture:
        "https://yanxuan-item.nosdn.127.net/c4295d879800d3280c483faa043ad6f2.png",
      specs: [
        {
          name: "颜色",
          valueName: "虎虎生威",
        },
        {
          name: "尺码",
          valueName: "90/3T",
        },
      ],
    },
    {
      id: "300476654",
      skuCode: "300476654",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 7700,
      picture:
        "https://yanxuan-item.nosdn.127.net/c4295d879800d3280c483faa043ad6f2.png",
      specs: [
        {
          name: "颜色",
          valueName: "虎虎生威",
        },
        {
          name: "尺码",
          valueName: "100/4T",
        },
      ],
    },
    {
      id: "300476655",
      skuCode: "300476655",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 6694,
      picture:
        "https://yanxuan-item.nosdn.127.net/c4295d879800d3280c483faa043ad6f2.png",
      specs: [
        {
          name: "颜色",
          valueName: "虎虎生威",
        },
        {
          name: "尺码",
          valueName: "110/5T",
        },
      ],
    },
    {
      id: "300476656",
      skuCode: "300476656",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 6358,
      picture:
        "https://yanxuan-item.nosdn.127.net/c4295d879800d3280c483faa043ad6f2.png",
      specs: [
        {
          name: "颜色",
          valueName: "虎虎生威",
        },
        {
          name: "尺码",
          valueName: "120/6T",
        },
      ],
    },
    {
      id: "300476657",
      skuCode: "300476657",
      price: "89.00",
      oldPrice: "99.00",
      inventory: 1467,
      picture:
        "https://yanxuan-item.nosdn.127.net/c4295d879800d3280c483faa043ad6f2.png",
      specs: [
        {
          name: "颜色",
          valueName: "虎虎生威",
        },
        {
          name: "尺码",
          valueName: "130/8T",
        },
      ],
    },
  ],
  categories: [
    {
      id: "1020003",
      name: "T恤/polo/衬衫",
      layer: 2,
      parent: {
        id: "1011000",
        name: "母婴",
        layer: 1,
        parent: null,
      },
    },
    {
      id: "1011000",
      name: "母婴",
      layer: 1,
      parent: null,
    },
  ],
  details: {
    pictures: [
      "https://yanxuan-item.nosdn.127.net/d17e93e318fb77fd2713ead61afc2182.jpg",
      "https://yanxuan-item.nosdn.127.net/e8f3c9a58d35c83fd6804e4737e4e719.jpg",
      "https://yanxuan-item.nosdn.127.net/ddd8b464451c653ae5ac57002c4efdf7.jpg",
      "https://yanxuan-item.nosdn.127.net/cbcf3d6758e066565060a4be93a7fe16.jpg",
      "https://yanxuan-item.nosdn.127.net/7d7219d20e8444d4765a997c78d43fbe.jpg",
      "https://yanxuan-item.nosdn.127.net/b1dba8f32a247a9faffca2ac660e669d.jpg",
      "https://yanxuan-item.nosdn.127.net/0c6658b1b6eaaee8e3e465a19300c019.jpg",
      "https://yanxuan-item.nosdn.127.net/9b19e6eae2f45e7d6aeb415b34040b31.jpg",
      "https://yanxuan-item.nosdn.127.net/3c04abfcef3f197e8380d4a55fccf597.jpg",
      "https://yanxuan-item.nosdn.127.net/4eff6d25adb4f536bb2eca28db22f607.jpg",
      "https://yanxuan-item.nosdn.127.net/06deb54d0afff83f9b00715085bcbefe.jpg",
      "https://yanxuan-item.nosdn.127.net/ea03ffabcfc6911cc65bc5d845e9fe94.jpg",
      "https://yanxuan-item.nosdn.127.net/d585b18d12d47b116c00279a65d16fbf.jpg",
      "https://yanxuan-item.nosdn.127.net/c7bb82029b6361ce7ccd7724a2124862.jpg",
      "https://yanxuan-item.nosdn.127.net/d608366ee6a20114d6322814e0a48400.jpg",
      "https://yanxuan-item.nosdn.127.net/ac30264177687707e50f21a2947d3141.jpg",
      "https://yanxuan-item.nosdn.127.net/fa4d4a09ad82397eefc96b6a7491d31c.jpg",
      "https://yanxuan-item.nosdn.127.net/b30c0f70aa5cd2da2cb2448667ca9bae.jpg",
      "https://yanxuan-item.nosdn.127.net/38e4d4562b3d430615f0838a7faac64d.jpg",
      "https://yanxuan-item.nosdn.127.net/5d530bac8541366fb6ffbf8d9b46abe2.jpg",
      "https://yanxuan-item.nosdn.127.net/55d58e4e56887fe4bf3ab71e67f60330.jpg",
      "https://yanxuan-item.nosdn.127.net/8e7612d375c9dcd106c4af9740491b7d.jpg",
      "https://yanxuan-item.nosdn.127.net/26477e517e78622d8368b422540b8cb2.jpg",
      "https://yanxuan-item.nosdn.127.net/ae5ff32cb427f7868baeb561d2bcc2fd.jpg",
      "https://yanxuan-item.nosdn.127.net/1fef8d0341d9f57f8204e4c020745873.jpg",
      "https://yanxuan-item.nosdn.127.net/3d7693d682558799fed44720771cbdce.jpg",
      "https://yanxuan-item.nosdn.127.net/6cd9467938fb02900b68b5b36649621b.jpg",
      "https://yanxuan-item.nosdn.127.net/6e90b89bd6bd9c593c23bf268667c10b.jpg",
      "https://yanxuan-item.nosdn.127.net/ca0f4bb95d65c0ee9db77e234dd48bf8.jpg",
      "https://yanxuan-item.nosdn.127.net/f8770e70e62abab241bc2ebfed6e7755.jpg",
      "https://yanxuan-item.nosdn.127.net/6cb5044aa46f7d1df38dd02ab3d44f24.jpg",
      "https://yanxuan-item.nosdn.127.net/b07d7218574c00ed279b3cb9f1398320.jpg",
      "https://yanxuan-item.nosdn.127.net/d731e365803d74ed86a1d7c7e8b3604d.jpg",
      "https://yanxuan-item.nosdn.127.net/406e5e1d6c651a2517d710759bca306a.jpg",
      "https://yanxuan-item.nosdn.127.net/69aabbe9990ca3f79e46fc945166bd66.jpg",
      "https://yanxuan-item.nosdn.127.net/e247235d6fde2b1ce33e9e5fed08fe8f.jpg",
      "https://yanxuan-item.nosdn.127.net/1a7e7b38f0af73d3edb337073a5af41b.jpg",
      "https://yanxuan-item.nosdn.127.net/83e836d1be1c1957ecffd76eb50b0c6c.jpg",
      "https://yanxuan-item.nosdn.127.net/41345cc53355f6f1863e90ccd7df9771.jpg",
      "https://yanxuan-item.nosdn.127.net/b65bb51e5861b8dc374d66a3b433f1b7.jpg",
      "https://yanxuan-item.nosdn.127.net/54f5f2627e313f3fde873844224d1659.jpg",
      "https://yanxuan-item.nosdn.127.net/5294d195515c3294cdbabd8a52e33218.jpg",
      "https://yanxuan-item.nosdn.127.net/b7f8927b0de3839310c8b4f79849fb9a.jpg",
      "https://yanxuan-item.nosdn.127.net/218d344e97bfcef2e74cb9e5630e62d6.jpg",
      "https://yanxuan-item.nosdn.127.net/cdd1b0bd042f057e44dd55aa1dfee5b7.jpg",
      "https://yanxuan-item.nosdn.127.net/35430c0c6189f7b95d1bdbee49ac0a92.jpg",
      "https://yanxuan-item.nosdn.127.net/818c8a68280ab6303b6221907a55f2ae.jpg",
      "https://yanxuan-item.nosdn.127.net/b4ccfb0228842390f344b28ea52e35ba.jpg",
      "https://yanxuan-item.nosdn.127.net/f7da636a5d2cd961fc0be9d20d6e2f15.jpg",
      "https://yanxuan-item.nosdn.127.net/bbdabd2d986ebeb89fa01dc198b8a8f2.jpg",
      "https://yanxuan-item.nosdn.127.net/e80c854997e5c55abc2f7d55470670ee.jpg",
      "https://yanxuan-item.nosdn.127.net/7631ece110dd899564e8d238ffb79bfe.jpg",
      "https://yanxuan-item.nosdn.127.net/5473bcfa52b15a9dca4bdeb5c1c482e7.jpg",
      "https://yanxuan-item.nosdn.127.net/9ca4698ff1d5a183f112d0fccb7ced6b.jpg",
      "https://yanxuan-item.nosdn.127.net/4b1c3e76526d1d7023c462f92ca18015.jpg",
      "https://yanxuan-item.nosdn.127.net/7ff5cddbfc1055da72cfd99cc1115a93.jpg",
      "https://yanxuan-item.nosdn.127.net/be47b6b98e491008a687cf18b245a8c0.jpg",
      "https://yanxuan-item.nosdn.127.net/0561fa21a81133ba363f25d0add8eace.jpg",
      "https://yanxuan-item.nosdn.127.net/1a06a83166e3c4e43dd06453d724267e.jpg",
      "https://yanxuan-item.nosdn.127.net/39162ded2a6da88708d82e5afa4d8f16.jpg",
      "https://yanxuan-item.nosdn.127.net/e4fe6b8bf1baaa33237afa670934b701.jpg",
      "https://yanxuan-item.nosdn.127.net/c87bb208152b3814bad19afd155b77d5.jpg",
      "https://yanxuan-item.nosdn.127.net/9ab53d066ec4d33587334def3a6cccef.jpg",
      "https://yanxuan-item.nosdn.127.net/a420c92c75d032ee854bb0946b241799.jpg",
      "https://yanxuan-item.nosdn.127.net/738a75098f8c6239ab1315bcb7e7bd20.jpg",
      "https://yanxuan-item.nosdn.127.net/49fc67071c6cf3c9a703c81b4800f23f.jpg",
      "https://yanxuan-item.nosdn.127.net/99c93c82f6fd01582de3e96c467ab6ea.jpg",
      "https://yanxuan-item.nosdn.127.net/5e0e0b4bb32438eb0ec9fa3d8652bfaa.jpg",
      "https://yanxuan-item.nosdn.127.net/47df78d6e94cdbdab0d72c60df0d19cc.jpg",
      "https://yanxuan-item.nosdn.127.net/381c6f919afa6bfa64880362d1494cf3.jpg",
      "https://yanxuan-item.nosdn.127.net/8e1a8903754deafe6152ba1ee768a99f.jpg",
      "https://yanxuan-item.nosdn.127.net/098089e43d777a61053bef0c77e0b883.jpg",
      "https://yanxuan-item.nosdn.127.net/4c8a2555193f539f00925d8229b5c05d.jpg",
      "https://yanxuan-item.nosdn.127.net/9ca474dc6aec7e2ec0587fe7313105dd.jpg",
      "https://yanxuan-item.nosdn.127.net/c8143393d1084032e414a6214d15dae3.jpg",
      "https://yanxuan-item.nosdn.127.net/7ac2c5699f498fb6f60f7ce3de8b96a1.jpg",
      "https://yanxuan-item.nosdn.127.net/0f332e0dbf44d9774fdd343f26b7715c.jpg",
      "https://yanxuan-item.nosdn.127.net/83384d1a1f9a6b009e3e88b2ef89c876.jpg",
      "https://yanxuan-item.nosdn.127.net/199e0f8b90abe0c0983e332a8ab9ddff.jpg",
      "https://yanxuan-item.nosdn.127.net/44b8382e9e6fc5a6d6ee6ef3baeb2239.jpg",
      "https://yanxuan-item.nosdn.127.net/5536540a65c6afd305ed406ada3873dd.jpg",
      "https://yanxuan-item.nosdn.127.net/2e201a00df378a8f48c5aac9aa58372b.jpg",
      "https://yanxuan-item.nosdn.127.net/afe227741ce4e671ab0aaa3fbe3a8d4f.jpg",
      "https://yanxuan-item.nosdn.127.net/ddaf4b11f6847651be7d4b044eed71a5.jpg",
      "https://yanxuan-item.nosdn.127.net/4caf6c944bab2c9a30e6f02ec2ca76ad.jpg",
      "https://yanxuan-item.nosdn.127.net/c9231f3599f439c46d90cdff2532ae44.jpg",
      "https://yanxuan-item.nosdn.127.net/6de91bd515adc52f0a980926b30665e0.jpg",
      "https://yanxuan-item.nosdn.127.net/a3f392c48bd65c18cd3d7b15d5c1396b.jpg",
      "https://yanxuan-item.nosdn.127.net/7f3e5580f8e94448849aac4e4b601d61.jpg",
      "https://yanxuan-item.nosdn.127.net/ab9e512c04c6d6fbb8e4f425aa44612d.jpg",
      "https://yanxuan-item.nosdn.127.net/6af30d522d20c8696f58e1e688a4036f.jpg",
      "https://yanxuan-item.nosdn.127.net/597b0034cb4b84dcb2bde9ba60333fd1.jpg",
      "https://yanxuan-item.nosdn.127.net/e247c6bc5baba78601bfdebdb8829b3a.jpg",
      "https://yanxuan-item.nosdn.127.net/efdd69b7d9c956f85170eacc08f99304.jpg",
      "https://yanxuan-item.nosdn.127.net/160c90570c1eb0a0af3a5d0966e855ff.jpg",
      "https://yanxuan-item.nosdn.127.net/640f093d53e6cdfc8e23c65ac63f2e6c.jpg",
      "https://yanxuan-item.nosdn.127.net/2b276d2aed400069f5c9dea9cb5dced1.jpg",
      "https://yanxuan-item.nosdn.127.net/e479b7a227a3131cff82d221b6b1422c.jpg",
      "https://yanxuan-item.nosdn.127.net/fa7c9753074ad17ec0765bba0f59359a.jpg",
      "https://yanxuan-item.nosdn.127.net/fda8bceff12917a908a89325c5e7f9f1.jpg",
      "https://yanxuan-item.nosdn.127.net/07252a52be03d361a39ccdd22680699a.jpg",
      "https://yanxuan-item.nosdn.127.net/e79fde61c3a1dd927766fecf188aafce.jpg",
      "https://yanxuan-item.nosdn.127.net/6eb88f082686ad9bbc429c17e8b38073.jpg",
    ],
    properties: [
      {
        name: "适用年龄",
        value: "6-9岁、3-6岁、1-3岁、0-1岁",
      },
      {
        name: "适用季节",
        value: "冬、秋、春秋",
      },
      {
        name: "材质",
        value: "纯棉",
      },
    ],
  },
  isPreSale: false,
  isCollect: false,
  recommends: null,
  userAddresses: [
    {
      id: "1842093282406961154",
      receiver: "肥锋快来救我",
      contact: "123333",
      provinceCode: "河北省",
      cityCode: "秦皇岛市",
      countyCode: "海港区",
      address: "王者峡谷",
      isDefault: 1,
      fullLocation: "",
      postalCode: "42513",
      addressTags: "打野",
    },
    {
      id: "1842094577398321153",
      receiver: "小明狗",
      contact: "124455555",
      provinceCode: "山西省",
      cityCode: "忻州市",
      countyCode: "神池县",
      address: "王者峡谷",
      isDefault: 1,
      fullLocation: "",
      postalCode: "42513",
      addressTags: "打野",
    },
    {
      id: "1842105517023956994",
      receiver: "柚子",
      contact: "10829993372",
      provinceCode: "11",
      cityCode: "1101",
      countyCode: "110101",
      address: "教室",
      isDefault: 1,
      fullLocation: "东城区",
      postalCode: "xxx",
      addressTags: "学校",
    },
    {
      id: "1842107196725268481",
      receiver: "蜂蜜柚子",
      contact: "111",
      provinceCode: "11",
      cityCode: "1101",
      countyCode: "110105",
      address: "教室",
      isDefault: 1,
      fullLocation: "朝阳区",
      postalCode: "xxx",
      addressTags: "学校",
    },
    {
      id: "1846201220872540161",
      receiver: "慕容复",
      contact: "13966666666",
      provinceCode: "320000",
      cityCode: "320500",
      countyCode: "320508",
      address: "慕容山庄1",
      isDefault: 1,
      fullLocation: "江苏省 苏州市 姑苏区",
      postalCode: "415366",
      addressTags: "姑苏慕容",
    },
    {
      id: "1846201377668206594",
      receiver: "慕容复uerqwroiqwuoiqru",
      contact: "13966666666",
      provinceCode: "320000",
      cityCode: "320500",
      countyCode: "320508",
      address: "慕容山庄1",
      isDefault: 1,
      fullLocation: "江苏省 苏州市 姑苏区",
      postalCode: "415366",
      addressTags: "姑苏慕容",
    },
    {
      id: "1846202136338108417",
      receiver: "慕容复uerqwroiqwuoiqru",
      contact: "13966666666",
      provinceCode: "320000",
      cityCode: "320500",
      countyCode: "320508",
      address: "慕容山庄1",
      isDefault: 1,
      fullLocation: "江苏省 苏州市 姑苏区",
      postalCode: "415366",
      addressTags: "姑苏慕容",
    },
    {
      id: "456878463",
      receiver: "蔡徐坤四号、",
      contact: "1111111111",
      provinceCode: "江苏省的行政编码",
      cityCode: "苏州市的行政编码",
      countyCode: "姑苏区的行政编码",
      address: "111",
      isDefault: 1,
      fullLocation: "",
      postalCode: "11",
      addressTags: "111",
    },
    {
      id: "8455018378656685045",
      receiver: "五千万",
      contact: "1254555346",
      provinceCode: "江苏省的行政编码",
      cityCode: "苏州市的行政编码",
      countyCode: "姑苏区的行政编码",
      address: "哈哈",
      isDefault: 1,
      fullLocation: "",
      postalCode: "415366",
      addressTags: "姑苏慕容",
    },
    {
      id: "1846805588177063938",
      receiver: "王五",
      contact: "1636475554",
      provinceCode: "112",
      cityCode: "1111",
      countyCode: "1111",
      address: "223",
      isDefault: 0,
      fullLocation: "",
      postalCode: "1111",
      addressTags: "11111",
    },
  ],
  similarProducts: [
    {
      id: "4026450",
      name: "趣味小恐龙绣花，男童灯芯绒衬衫",
      desc: "趣味小恐龙绣花，满版老虎印花，5色可选",
      price: "89.00",
      picture:
        "https://yanxuan-item.nosdn.127.net/e68d406a58622a8d850de442aacfcf2e.jpg",
      orderNum: 8204,
    },
    {
      id: "4007498",
      name: "ins风小碎花泡泡袖衬110-160cm",
      desc: "全棉面料，高支高密底布，手感柔软舒适，贴身穿着亲肤透气；经典娃娃衫，泡泡袖设计，增添可爱蓬松感；后背全开门襟，方便穿脱。",
      price: "99.00",
      picture:
        "https://yanxuan-item.nosdn.127.net/c07edde1047fa1bd0b795bed136c2bb2.jpg",
      orderNum: 7506,
    },
    {
      id: "4026178",
      name: "经典格子元素，男童格子纯棉衬衫",
      desc: "经典格子元素，侧边小贴袋装饰，5色可选",
      price: "89.00",
      picture:
        "https://yanxuan-item.nosdn.127.net/22cba953b8239943c6db9cd0715bc2d2.jpg",
      orderNum: 2854,
    },
    {
      id: "3994470",
      name: "复古格调，儿童灯芯绒衬衫73-130cm",
      desc: "竖条灯芯绒纹理，凸显肌理层次",
      price: "99.00",
      picture:
        "https://yanxuan-item.nosdn.127.net/09ae7983369f9ddfba6ea96670ca84a7.png",
      orderNum: 3262,
    },
  ],
  hotByDay: [
    {
      id: "4026450",
      name: "趣味小恐龙绣花，男童灯芯绒衬衫",
      desc: "趣味小恐龙绣花，满版老虎印花，5色可选",
      price: "89.00",
      picture:
        "https://yanxuan-item.nosdn.127.net/e68d406a58622a8d850de442aacfcf2e.jpg",
      orderNum: 8204,
    },
    {
      id: "4026116",
      name: "探险者黑胶防晒防雨遮阳伞户外钓鱼伞",
      desc: "防雨遮阳隔绝紫外线",
      price: "169.00",
      picture:
        "https://yanxuan-item.nosdn.127.net/66090c5de391e43e4516601e14870842.jpg",
      orderNum: 9018,
    },
    {
      id: "1108008",
      name: "爆款明星好物，抽屉式透明储物柜",
      desc: "抽屉随意拉，东西随意拿，7款尺寸，随意叠加搭配",
      price: "129.00",
      picture:
        "https://yanxuan-item.nosdn.127.net/76a5304c9d7378a83e63554f3077d98b.png",
      orderNum: 4128,
    },
    {
      id: "1028004",
      name: "衣柜省空间神器，棉麻涤·收纳挂袋",
      desc: "实用棉麻，悬挂牢固",
      price: "55.00",
      picture:
        "https://yanxuan-item.nosdn.127.net/49e21db0fe13c0ff1789a79a8ba48468.jpg",
      orderNum: 2702,
    },
  ],
  evaluationInfo: {
    id: "1497559523202699266",
    orderInfo: {
      specs: [],
      quantity: 1,
      createTime: null,
    },
    member: null,
    score: 5.0,
    tags: null,
    content: "系统默认好评",
    pictures: null,
    officialReply: null,
    praiseCount: 682,
    createTime: "2022-02-26 21:09:48",
    praisePercent: 1.0,
  },
});
// const getGoods = async () => {
//   const res = await getDetail(4026450);
//   goods.value = res.result;
//   console.log("测试数据skiu", goods);
// };
// onMounted(() => {
//   getGoods();
// });

// 生成有效路径字典对象

const getPathMap = (goods) => {
  const pathMap = {};

  // 1.根据Sku字段生成有效的sku数组
  const effectiveSkus = goods.skus.filter((sku) => sku.inventory > 0);

  //   2.根据有效的sku使用算法 (子集算法)[1,2]=> [[1],[2],[1,2]]
  effectiveSkus.forEach((sku) => {
    // 2.1获取匹配的valueName组成的数组
    const selectedValArr = sku.specs.map((val) => val.valueName);
    // 2.2使用算法获取子集
    const valueArrPowerSet = powerSet(selectedValArr);
    // 3.把得到的子集2生成最终的路径字典对象
    valueArrPowerSet.forEach((arr) => {
      // 初始化key 数组 join 遍历为字符串

      const key = arr.join("-");
      //   判断 如果存在当前的key了 就往数组中直接添加 如果不存在 直接赋值

      if (pathMap[key]) {
        pathMap[key].push(sku.id);
      } else {
        pathMap[key] = [sku.id];
      }
    });
  });
  return pathMap;
};

// 初始化禁用状态 遍历每一个规格对象 使用name字段去路径字典pathMap中匹配 匹配不上则禁止
const initDisabledStatus = (specs, pathMap) => {
  specs.forEach((specs) => {
    specs.values.forEach((val) => {
      if (pathMap[val.name]) {
        // 匹配上了 可选
        val.disabled = false;
      } else {
        // 没匹配上 不可选
        val.disabled = true;
      }
    });
  });
};
const pathMap = getPathMap(goods.value);
initDisabledStatus(goods.value.specs, pathMap);

// 切换选中状态--选中和取消选中
const changeSku = (item, val) => {
  if (val.disabled) return;
  // item 同排对象
  // val 当前点击项
  if (val.selected) {
    val.selected = false;
  } else {
    item.values.forEach((val) => (val.selected = false));
    val.selected = true;
  }
  //   点击按钮更新
  updateDisableStatus(goods.value.specs, pathMap);
  //   产出SKu对象
  const index = getSelectedValues(goods.value.specs).findIndex(
    (item) => item === undefined
  );
  if (index > -1) {
    console.log("找到了信息不完整");
  } else {
    console.log("当前信息是完整的");
    // 获取完整sku对象 -- 通过选中拼接 再去路径字典中查找 skuID
    const key = getSelectedValues(goods.value.specs).join("*");
    const skuIds = pathMap[key];
    // 拿到id去skus中去查找对象--
    // 通过skuId作为匹配项 去goods.values.skus数组中找
    const skuObj = goods.value.skus.find((item) => item.id === skuIds[0]);
    console.log("sk对象为", skuObj);
    // 拿到skuObj
  }
};

// 获取选中项的匹配数组
const getSelectedValues = (specs) => {
  const arr = [];
  specs.forEach((specs) => {
    // 目标：找到values中selected为true的项，然后把它的name字段添加到数组对应位置
    const selectedVal = specs.values.find((item) => item.selected);
    arr.push(selectedVal ? selectedVal.name : undefined);
  });
  return arr;
};

// 切换时更新禁用状态
const updateDisableStatus = (specs, pathMap) => {
  specs.forEach((spec, index) => {
    const selectedValues = getSelectedValues(specs);
    specs.values.forEach((val) => {
      selectedValues[index] = val.name;
      const key = selectedValues.filter((value) => value).join("-");
      if (pathMap[key]) {
        // 找到了 不禁用
        val.disabled = false;
      } else {
        // 没找到 禁用
        val.disabled = true;
      }
    });
  });
};
</script>


  
<template>

  <div class="goods-sku">
    <dl
      v-for="item in goods.specs"
      :key="item.id"
    >
      <dt>{{ item.name }}</dt>
      <dd>
        <template
          v-for="val in item.values"
          :key="val.name"
        >
          <!-- 图片类型规格 -->
          <img
            v-if="val.picture"
            :src="val.picture"
            :title="val.name"
            :class="{selected:val.selected,disabled:val.disabled}"
            @click="changeSku(item,val)"
          />
          <!-- 文字类型规格 -->
          <span
            v-else
            :class="{selected:val.selected,disabled:val.disabled}"
            @click="changeSku(item,val)"
          >
            {{ val.name }}
          </span>
        </template>
      </dd>
    </dl>
  </div>

</template>

  <style scoped lang="scss">
@mixin sku-state-mixin {
  border: 1px solid #e4e4e4;
  margin-right: 10px;
  cursor: pointer;

  &.selected {
    border-color: $xtxColor;
  }

  &.disabled {
    opacity: 0.6;
    border-style: dashed;
    cursor: not-allowed;
  }
}

.goods-sku {
  padding-left: 10px;
  padding-top: 20px;

  dl {
    display: flex;
    padding-bottom: 20px;
    align-items: center;

    dt {
      width: 50px;
      color: #999;
    }

    dd {
      flex: 1;
      color: #666;

      > img {
        width: 50px;
        height: 50px;
        margin-bottom: 4px;
        @include sku-state-mixin;
      }

      > span {
        display: inline-block;
        height: 30px;
        line-height: 28px;
        padding: 0 20px;
        margin-bottom: 4px;
        @include sku-state-mixin;
      }
    }
  }
}
</style>
  